/**
 * Xilinx PL/AXI-GPIO 驱动适配层
 * 张勇 / 41204@qq.com
 */
#include <stdbool.h>
#include <xparameters.h>
#include <xintc.h>
#include "gpio.h"

int scugic_intr_type(gpio_intr_type_t trig) {
	/**/ if(trig == GPIO_INTR_POSEDGE) return 3; // 0x3：上升沿触发
	else if(trig == GPIO_INTR_NEGEDGE) return 2; // 0x2：下降沿触发
	else if(trig == GPIO_INTR_LVHIGH)  return 1; // 0x1：高电平触发
	else if(trig == GPIO_INTR_LVLOW)   return 0; // 0x0：低电平触发
	else return -1;
}

int scugic_intr_type_toggle_polarity(uint8_t irq_type) {
	/**/ if(irq_type == 3) return 2;
	else if(irq_type == 2) return 3;
	else if(irq_type == 1) return 0;
	else if(irq_type == 0) return 1;
	else return -1;
}
